binary int writing function