Serialize error class and message separately

Fixes #42.
Fixes #43.

This changes the internal representation of failures to be easier to serialize and deserialize. It also makes `.from_json` able to handle failure by returning a failure describing the deserialization problem. This will allow it to handle changes to the serialization format in the future.

@justinsteffy: can you review this?