Hi there,
Struggling a bit as to where I should add the extension ".tif". I would say:
          outname = os.path.join(res_ws, "cellstat{0}".format(i).tif)
However, I still get an error message, different one though:
File "E:\Software\new_script_geonet_revB.py", line 45, in <module>
    main()
  File "E:\Software\new_script_geonet_revB.py", line 26, in main
    outname = os.path.join(res_ws, "cellstat{0}".format(i).tif)
AttributeError: 'str' object has no attribute 'tif'