Remove int return value from Encode

And remove a bunch of bookkeeping code related to it.

AND fix a bug covered up by it, where nil was returned instead of err.