added encode.c