Fix memory leak in Encode.xs