Debug mode with command line option

Instead of having to recompile the application to enable and disable
outputting debug images, use the -d command line option. This generates
some warnings since DEBUG isn't used in all files options.h is included
in, which needs to be fixed; however, this majorly reduces the run time
if we don't need to be outputting those images.
Only exit a thread if the queue is empty

We want to exit after requesting the results AND the data has been
processed. This fixes the issue where you have less threads than items
to process, which will happen very frequently.
Single extern DEBUG global variable

We'll use 'extern bool DEBUG' since otherwise we can't globally modify
it from within main().