Adapt image code to API changes