Rewrite writer/encoder and add Decodable interface.
Fix Decodable test.
Add Encodable interface.