proper scaled creation of image
bug fix and moved the render code