fixing image draw function