It sounds like you are making pretty good progress.
As I understand it, the image is returned to the client as FITS when ExposureComplete(&PrimaryCCD) is used. The image buffer to write your image to is set with the uint8_t *image = PrimaryCCD.getFrameBuffer() line in the generic_ccd example. Then write your image data to the frame buffer ('image' in this case). If the parameters such as height and width are set correctly, a conversion to FITS is performed and the image is sent to the client.