Fix free memory on stack in encode()