the most easy way to do this in a script is to use the subprocess module and gdal_translate


    import subprocess
    
    image_in = "path_input_image"
    image_out = "path_output_image.tif"
    subprocess.call(["gdal_translate.exe","-co", "TILED=YES", "-co", "COMPRESS=LZW" "-ot", "Byte", "-scale", image_in, image_out ]

if you are in Linux, you don't need the ".exe" after gdal_translate, and if gdal is not installed, you might need to provide the full path to the application