writeOutputImage() relocated