There was a book called Bit-Mapped Graphics, I think, which had code in assembly language to encode and decode a number of image file formats including GIF. Newer editions had code in C.