Added code to refresh image while being drawn