Use minimal try-except blocks in NumpyJSONEncoder and add a test