Fix bug in image function