Catch better json-encoding exceptions

EncodingError is superclass of Encoding::UndefinedConversionError,
and also Encoding::ConverterNotFoundError