write media stream to a file