fix pyflakes & pep8 on write