I’m skeptical that `.encode('latin1')` is the right thing to do here. Can you explain/justify it?

Note that this file is about dealing with API changes between different Python versions. It should do as little as possible beyond this. Perhaps this belongs in `pdf.py`. (But the above still applies.)