Fixed UnicodeEncodingError that appears while running flake8 in TeamCity
There is an issue (https://github.com/JetBrains/teamcity-messages/issues/122): checking files with flake8 formatting plugin for TeamCity failes with UnicodeEncodingError if the files contains non-ASCII charecters.
I've done some analisys that shows the problem in the following: teamcity plugin puts lines of code from the checked file where flake8 had found an error and returns the error message from format() method in Unicode. Then when flake8 is going to write the error message into file or stdout it doesn't expect non-ASCII symbols in it and raised UnicodeEncodingError.
I've made small changes that check the type of output lines and encode it to UTF-8 in case it is Unicode before writing it to outputfile or stdout. I think this will solve the problem.