add missing os import and fix undefined gen_log

import absence resulted in incorrect behaviour of ZMQIOLoop's
`close` method. Also fixed `gen_log` variable NameError.