The LEGO Mindstorms EV3 uses an undocumented image format, RGF, to save and load images. Fortunately, after inspecting a few RGF files in a hex editor, it turns out the format is quite simple.
The first byte stores the image width as an 8-bit unsigned integer. The second byte stores the height as an 8-bit unsigned integer.
Since the EV3 can only display 1-bit images, a bit stream of 0s and 1s follows, each bit representing a pixel in row major order.
The total file size is thus 2 + ceil(width * height / 8)
.
Hope this helps!