Updated to work with Python 3.X

Thanks to suggestion by @runasand, made changes to be forward compatible
and work with Python 2.X and 3.X. This required numerous small updates
to handle different printing and text file parsing.