add -fPIC for linux.
fix typo.
encode can only take buffers.