reorganized gif optimize to work with palette parameter