Assume gray8 if 1 < maxval <= 255 in pgm.