python 3 compatibility and convert tab to space