fixed utf-8 encoding issue for python3, made sure that cleaup is performed after keyboard interrupt