fixed binary function write