Fix pep8 warnings and change string formating to str.format