Fix TypeErr: expected bytes but str is passed.