Logfile: fix FileWrapper for Python2

Due to changes between Python2 and Python3, the FileWrapper class added in PR #47 didn't work for Python2. 

The version of Python is now checked, and the appropriate class definition is used.