Fixed .encode error (returns byte array in Python 3+) using try/catch.
Merge pull request #11 from karma0/python3

Fixed to run on Python versions 2 and 3