Always read binary files with mode rb
Always write binary files in mode wb
Use write to avoid newline problems