how to read and write binary file in python