The code that you are using should be installed separately from the normal python installation, in fact comes from PIL libray (Python Imaging Library) which is an external library, an add on.
Beware that the PIL library doesn't work on python version 3.0 and over, but is still working only on python 2.x series, so if you have python 3.x installed you should first install a python 2.x and than download and install the corresponding PIL Library.
Here a link to PIL library, you can download from here.