fix cache bug
wrap the get_average_image function