handle test failures with encode('utf-8')'s interaction with StringIO