Fix image insertion code