PHP code for writing hexadecimal to file