you should open in binary mode : "wb+"