Added workaround for the fact that np.pad does not exist for old versions of Numpy