Parallelize writing images.

1. Added WriteImage to write out images from a buffer.
2. Start 3 WriteImage threads if saving.