Maybe you could write out your image in NetPBM's PPM
format which is extremely simple and documented on Wikipedia here.
So, for example the following (enlarged) 3x2 image:

would look like this (the part following #
on each line is my comment):
P3 # P3 means ASCII, 3-channel RGB
3 2 # width=3, height=2
255 # MAX=255, therefore 8-bit
255 0 0 0 255 0 0 0 255 # top row of pixels in RGB order
0 255 255 255 0 255 255 255 0 # bottom row of pixels in RGB order
Then you can use ImageMagick, which is installed on most Linux distros and is available for macOS and Windows to make that into a BMP at the command line like this:
magick input.ppm output.bmp
or, if you want a JPEG with contrast stretch and resized to 800x600:
magick input.ppm -resize 800x600 -auto-level output.jpg
You can equally do the conversion with GIMP, Adobe Photoshop, probably MS Paint, probably IrfanView, or using the NetPBM toolkit. For example, with the NetPBM tools (which are much lighter weight than ImageMagick) the conversion would be:
ppmtobmp image.ppm > result.bmp