add support to save sample to file