image/gif: fix GIF encoding of sub-images.

benchmark                    old ns/op     new ns/op     delta
BenchmarkEncode              8641055       8646829       +0.07%

Fixes issue 7792.

LGTM=r
R=r
CC=dbathgate, golang-codereviews
https://codereview.appspot.com/147730043