Simplify image loading code