improve logging
py3 compat