Fix memory leak in output rendering