Fixed logging to a file since it didn't work anymore.

Logging to a file was broken since ```logging.FileHandler``` was not imported and it conflicted with the logging from cubes. I changed it a little to support logging to a file and I cleaned up the code.