however when the result is viewed with ArcCatalog/ArcGIS, it looks either black or grey, since it has no statistics. This is solved either by right-clicking the raster and choosing "Calculate Statistics..." in ArcCatalog (there are several other ways to do this), or using gdalinfo in a command prompt:

gdalinfo -stats MyRaster.tif

will generate MyRaster.tif.aux.xml, which is used by ArcGIS to properly scale the raster. The PAM (Persistent Auxiliary Metadata) file contains the statistics, most notably the minimum and maximum values:

It turns out that band.GetStatistics(0,1) will actually calculate the statistics, and add it to the GeoTIFF metadata in the single file. No other files required. However from testing with Esri products, it only works with ArcGIS 10.0 and up, not ArcGIS 9.3 or before.
– Mike TJul 17 '12 at 8:58

The function is described on the GDAL Page. Based on that, the two arguments passed to the function are bApproxOK (if TRUE statistics may be computed based on overviews or a subset of all tiles) and bForce (if FALSE statistics will only be returned if it can be done without rescanning the image).
– user78826Dec 22 '16 at 17:29

If the statistics are already calculated and included in the file internally, gdalinfo -stats wont create a additional PAM statistics file(.aux.xml) for using GDAL 2.1.0. But its very easy to implement the .xml for your own. Here are some built-in Python modules explained to do that stuff. For myself i used The ElementTree XML API with the code below: