Better image resizing code.