Storing masks in jpg format I've created masks(numpy array with 0,1 as values) and tried exporting this array to jpg using matplolib but it's not exporting the values as it is. I'm getting a range of pixel values in resulting image. Is there any way in which I can add the array values to pixel values as it is. For example numpy array is 40X40 and resulting jpg image resolution is 40X40 pixels.
When you simply use say plt.savefig() to jpg, matplotlib by default does not save it to a binary image as you require. JPG by default the definition is values ranging from 0-255. 
Suggest using PIL instead of matplotlib then you can save as BW binary image.