add encoder api

still need a way to get buffers