Changed to write binary mode.