Extract building and encoding gif to new function

Added new `createImage(cellSize, margin)` function, that uses code
extracted from `createImgTag()` function. This allows user to call
`createImage()` to get raw GIF data (in a form of object, with `bytes`,
`width` and `height` properties) or `createImgTag` as before.