Generalized `encode` and `encodePut` to `Producer'`s.

See @Gabriel439's suggestion in issue #13.