fixed a bug with incorrect pnm reading