Added multithreaded jpeg encoding functionality