add more diagnostics to encoding issues