Add better handling of graphic files
Modify debug function

Add a debug function that writes the debug file only if the debug flag
is set