Read and write GIFs in Javascript