Solved by justusschock in post #6 
              
              
                Or you could do 
img = LOAD_YOUR_IMAGE
img += img.min()
img *= 255/img.max()
img = np.astype(np.uint8)

If your image is a numpy array (which I assume from your plotting code). This would work for all image ranges and would always use the full range of [0,255]. The disadvantage however would be that…