fixed QP encoder

Squashed commits:
- fixed qp encoder & non-utf8 charset bug
- fixed errors from native qp encoder
- fixed QP encoder tests