Issue #868 encoder mutating the shared message

Add copy on write semantics to the encoder write_message API
Clean up unit test
Merge pull request #870 from mozilla-services/issue_868

Issue #868 encoder mutating the shared message
Fix the message copy to handle nil, optional fields
Merge pull request #871 from mozilla-services/issue_868

Fix the message copy to handle nil, optional fields