PPM encoder: Support arbitrary bit depths from 1 to 16

Actually, it's more general than that: the number of color shades does not
have to be a power of 2. But the command line utility currently offers no way
to request such "fractional" bit depths.
Regression tests for writing PNM files
PNG encoder: If the colorspace is unsupported, don't write an sRGB chunk
Support writing PGM files