added logic to determine image type and world file extension