fixed a bug in Encoder in which string was used instead of bytes.