DRY up gif saving function