php based binary file reader and writer