Add python3 compatibility.

Added python3 compatibility while retaining python2 backwards-compatibility as well. Notably google_authenticator has a try/except import, the rest is just updating deprecated/obsolete syntax.