Implement Encode using encode_message_impl macro.

This fixes #1.