Fix case where encoding is None

This happens in our unittest.