Fixed InvalidByteSequenceError exception handling