Implementation of REP 143

Yes, it needs to write binary data.

If you would prefer the `codecs` module I would suggest to consider that in a separate pull.
It needs a lot of testing, e.g. generate cache with one Python version, use / update with another Python version.
Also you have to make sure that each cache update will actually find new package xml resources which contain non-ascii characters.