Refactored Image class and fixed php notices