Fixed leaking reference
Thanks for the pull request.
I think the Py_DECREF(*obj) line will cause us problems. As far as I see it we stand of at risk of actually deleting the object being encoded and possibly its entire sub structure.
Suppose the object we're decrefing is the root object which would have 1 or more references held to it. If the ref count is 1 and we decref it the refcount will hit 0 and the object and its sub objects will be deleted.
I played around with this myself using your old code and there's something fundamentally problematic with trying to retrofit this into the present encoder structures. Maybe we need some completely new thinking to make it work.