Implement message writer.

(Otherwise it's weird that sendMessage() passes some parameters on the stack and others on the heap)