Fix json

Error in Karol's merge request was that JSON and MARC need different handling of bytes; this uses BytesIO for MARC and StringIO for JSON; should pass tests on both Python 2 and 3.