Implementation of perceptual image hash calculation in Python