Use actual image type instead of hardcoded 'jpg'