try to fix invalid byte sequence errors