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!