Improve parsing of JSON and XML parsers by passing the encoding directly to the parsers.

This fixes an issue with JSON parser on Python3, but also utilizes the corresponding parser's encoding features.