fix python unicode length problem

fix issue #321

go use bytes length, not python unicode length. so need encode first.