How to save frames with negative/greater than 255 pixels

The following code fragments may help. They are used to write 16 bit monochrome images to a video file using FFV1 lossless compression. I don’t claim that they are elegant or efficient but they seem to be effective for my purposes. The resulting video file is twice as wide as the original image and the image is mangled, typically with vertical stripes but can be recovered with no loss.

    cv::Size2i RecordedImageSize = mimageSize;
    if (mmono16){
        RecordedImageSize.width = RecordedImageSize.width * 2;
    }
    int codec = cv::VideoWriter::fourcc('F', 'F', 'V', '1');			// lossless ffmpeg based codec
    bool isColour = !mmono16;
    compressedVideo.open(cprname.toLatin1().data(), codec, mframeRate, RecordedImageSize, isColour);    // Open the output

// This function writes each new frame to the output file as it is received
void VidRecord::inReceived(const cv::Mat & inframe){         // inframe is CV_16UC1 (16 bit monochrome)
    cv::Mat frame2b(inframe.rows, inframe.cols*2, CV_8UC1);  // Create output frame, double the number of 8 bit pixels as input
    frame2b.data = inframe.data;                             // point both Mat headers to the same block of data.
    compressedVideo.write(frame2b);                          // write image as alternating MSB, LSB pixels
}

// This code reads a mangled video frame and converts it back to 16 bit monochrome
    vcap.read(m_frame);                                     // read() always seems to return 8UC3 Mat, regardless of file format
    cv::Mat tframe;
    extractChannel(m_frame,tframe,0);                       // extract one of the color channels-- other two are identical
    m_frame2.create(tframe.rows, tframe.cols/2, CV_16UC1);  // Create output frame, half the number of 16 bit pixels as input
    m_frame2.data = tframe.data;                            // point both Mat headers to the same block of data--
    emit matReady(m_frame2);                                // effectively merge two adjacent 8 bit pixels into one 16 bit pixel