py3: convert exception to bytes to pass into ui.warn()
Here encoding.strtolocal() is used because exc maybe an IOError which could
contain a valid non-ascii unicode.
py3: convert bool variables to bytes before passing into ui.debug()
We can't pass unicodes to ui.debug() and hence we need to convert things to
bytes before passing them.