Implement message writer.

Does the code get simpler if you used a fixed mask? Maybe 0x4f4b6f6b ? (OKok)