Correctly saving binary files