Fixed problems when the default charset is not able to represent the bytestream