mesa: overhaul the glGetTexImage code