memory leak fixes

Fixes for two fairly significant leaks I found with the help of valgrind. The `ProcessObject` patch may fix issue #32, although that issue refers to `dumps()` and in my testing `dump()` was the primary source of leaked memory.