def pad_image(Image, rows, columns, fill=0):
    """
    Takes in an image file, returns a padded image to fit the rectangle given by the rows and columns dimensions
    :param Image: A PIL image object
    :param rows: integer, number of rows of pixels
    :param columns: integer, number of columns of pixels
    :param fill: an integer 1 or 0, indicating which color to fill the padded area with (1= white, 0 = black)
    :return: A PIL image object of dimensions (rows,columns) with the provided image in the center
    """
    # create new image of the desired size, with the fill
    padded = Image.new('1', (columns, rows), fill)
    incolumns, inrows = Image.size
    if incolumns > columns or inrows > rows:
        raise ValueError("Input image must be less than or equal to the output size in all dimensions.")
    # paste provided image into created image, such that it is as centered as possible in the new area
    padded.paste(Image, ((columns - incolumns) // 2, (rows-inrows) // 2))
    return padded