Added save to file function and compression