Working on gif handling. Not working yet.

libgif does not yet read all parts of the file
Fixed some resource leaks. Thanks, cppcheck!