st/dri: move some image functions to dri_helpers.c