Python3 Support and PEP8

-minor fixes for python3 support
-template directory based on file location
-code reformat based on PEP8 style-guide
-change depricated has_key to 'in' statements