Add support for P1 and P2 (ASCII) files

This C-style patch adds support for ASCII PGM and PBM files. 

Since I have no experience in Cocoa programming, the method I used could seem clunky, but it makes the job.