PGMReader: identify the pgm format correctly (issue #1263).

The pgm, ppm, and pbm formats are very similar formats, part of the netpbm
project.  While each of them has different 2-byte magic number at the
beginning of file, the current code only performs a check that is true for
all the 3 formats.  The PGM specific Magic numbers are "P2" and "P5" and this
change will limit this reader to them, avoiding incorrect reading of the
other formats.