Added basestring as a ref to str
Fixed 'StringIO' import for python3
Fixed problem with divisions truncation in python3
Ported code to python3 fixes #15