Changed print to output utf-8 only when default fails with UnicodeEncodeError.