open file to write with binary flag