Changed way of writing binary files