You can use PBM's 'rawtopgm' to convert three raw (r, g, b) files to pgm format. Then you can use pgm3toppm to convert the pgm files to a composite ppm file,
and feed this to cjpeg for compression. Slow, and circuitous, but it will
work.