tried to use the PGM format to solve the 16bit grayscale issue