Using print() function instead of print statement for python3 compatibility
Python 3 compatibility fixes

- Alternative StringIO import.

- Explicit relative imports.

- New octal syntax (0o777 instead of 0777)