Implemented images factory to minimize memory consumption