Updated mkgif() function.