Various small fixes to X509 code.

Bugs screwing up py3 or certificate signing.