moved the debug image writing to seperate method