handle UnicodeDecodeError exceptions when json encoding log messages