Make the source code Python 3 compatible

These changes have been tested using both Python 2 and Python 3. The plugin still does not work upon installation, since the .plugin file does not name the "python3" loader.