fix some encoding bugs