Gif Encoder in javascript