changed 'w' to 'wb' in for saving the file

and the same for reading ‘r’ -> ‘rb’