scripts: build: Add optimizations in file2hex.py to gzip path as well

Added recently introduced optimizations - generation in string literal form
and faster generation for hexadecimal initializer list form - to gzip path
as well.

Signed-off-by: Irfan Ahmad <irfan.ahmad@siemens.com>
diff --git a/scripts/build/file2hex.py b/scripts/build/file2hex.py
index 71336d0..b6e1acc 100755
--- a/scripts/build/file2hex.py
+++ b/scripts/build/file2hex.py
@@ -78,8 +78,14 @@
                     gz_obj.write(fg.read(args.length))
 
             content.seek(0)
-            for chunk in iter(lambda: content.read(8), b''):
-                make_hex(chunk)
+            if args.format == "literal":
+                print('"', end='')
+                for chunk in iter(lambda: content.read(1024), b''):
+                    make_string_literal(chunk)
+                print('"', end='')
+            else:
+                for chunk in iter(lambda: content.read(1024), b''):
+                    make_hex(chunk)
     else:
         with open(args.file, "rb") as fp:
             fp.seek(args.offset)