Extracted some of the database-code into ImageDAO