removed repeated code in Image class