Did some quick study on the .bmp format and converted the .pbm image to bitmap on the fly. The conversion is mostly automatic though I had to run an XOR (^) on all the bytes because pbm is inverted from bitmap. And, for some stupid reason, the bitmap images are upside down (starting from bottom left).

Anyhow, once in .bmp format, the options are a little more amenable.