Fixes a memory leak, and possible undefined behavior if we have
a serialization failure and just return the raw contents of a key.

Addresses issue #315
Merge branch 'hotfix/serializer_leak'