Fix crashes.
Implemented encoding of the video data using the lagarith code.