Repository: khronosgroup/gltf-blender-io
Issue: Exporting with "JPEG image" option selected throws exception when textures are not packed

When exporting to Gltf with option "JPEG format (.jpg)" selected, if textures are not packed into blend file it will throw an exception: 


```
Traceback (most recent call last):
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/__init__.py", line 483, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 40, in save
    json, buffer = __export(export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 53, in __export
    __gather_gltf(exporter, export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 62, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 37, in gather_gltf2
    scenes.append(__gather_scene(blender_scene, export_settings))
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 56, in __gather_scene
    node = gltf2_blender_gather_nodes.gather_node(blender_object, blender_scene, export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 46, in gather_node
    node = __gather_node(blender_object, blender_scene, export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 64, in __gather_node
    mesh=__gather_mesh(blender_object, export_settings),
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 337, in __gather_mesh
    export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_mesh.py", line 42, in gather_mesh
    primitives=__gather_primitives(blender_mesh, blender_object, vertex_groups, modifiers, material_names, export_settings),
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_mesh.py", line 129, in __gather_primitives
    export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py", line 64, in gather_primitives
    export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py", line 56, in gather_material
    pbr_metallic_roughness=__gather_pbr_metallic_roughness(blender_material, orm_texture, export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py", line 221, in __gather_pbr_metallic_roughness
    export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py", line 33, in gather_material_pbr_metallic_roughness
    base_color_texture=__gather_base_color_texture(blender_material, export_settings),
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py", line 107, in __gather_base_color_texture
    return gltf2_blender_gather_texture_info.gather_texture_info(inputs, export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py", line 37, in gather_texture_info
    index=__gather_index(blender_shader_sockets_or_texture_slots, export_settings),
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py", line 97, in __gather_index
    return gltf2_blender_gather_texture.gather_texture(blender_shader_sockets_or_texture_slots, export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture.py", line 48, in gather_texture
    source=__gather_source(blender_shader_sockets_or_texture_slots, export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture.py", line 97, in __gather_source
    return gltf2_blender_gather_image.gather_image(blender_shader_sockets_or_texture_slots, export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py", line 48, in gather_image
    uri = __gather_uri(image_data, mime_type, name, export_settings)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py", line 124, in __gather_uri
    data=image_data.encode(mime_type=mime_type),
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py", line 115, in encode
    return self.__encode_happy()
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py", line 121, in __encode_happy
    return self.__encode_from_image(self.blender_image())
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py", line 292, in __encode_from_image
    return _encode_temp_image(tmp_image, self.file_format)
  File "/home/ali/.config/blender/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py", line 308, in _encode_temp_image
    tmp_image.save()
RuntimeError: Error: Image 'Material_59.003_baseColor.png.001' does not have any image data


location: <unknown location>:-1


```
Linux OS
Blender v2.81
Gltf Addon v1.2.6

A test blend file: https://github.com/KhronosGroup/glTF-Blender-IO/files/4116950/untitled.blend.zip (Make sure to unpack texture before exporting)

Changed files:
addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py

diff --git a/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py b/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py
index 0a9fbc42..4b14a70e 100644
--- a/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py
+++ b/addons/io_scene_gltf2/blender/exp/gltf2_blender_image.py
@@ -284,6 +284,7 @@ class ExportImage:
         tmp_image = None
         try:
             tmp_image = image.copy()
+            tmp_image.update()
             if image.is_dirty:
                 tmp_image.pixels = image.pixels[:]
 
@@ -298,9 +299,6 @@ def _encode_temp_image(tmp_image: bpy.types.Image, file_format: str) -> bytes:
         tmpfilename = tmpdirname + '/img'
         tmp_image.filepath_raw = tmpfilename
 
-        # NOT A TYPO!!! If you delete this line, the
-        # assignment on the next line will not work.
-        tmp_image.file_format
         tmp_image.file_format = file_format
 
         tmp_image.save()