format code / minor style improvements
fix for UnicodeDecodeError