fix output image for numThreads > 1 ; misc code cleanup