Add custom json.loads method.

This allows us to support the use of an `str` parameter that won't be
converted to unicode.
So in the case of a string containing bytes with different encodings
this won't break.
Fix encodings usage, use custom json.loads method.

Also remove some unused imports.
Update VERSION_COMPAT, add changes file for #4838.