Properly free output for write ffmpeg