Gracefully handle encoding errors