def paste_tile(bg, fg):
    """Pastes multiple copies of fg onto bg in a tiled pattern."""
    nw = bg.size[0] / fg.size[0] + 1
    nh = bg.size[1] / fg.size[1] + 1
    for t in range(nh):
        for l in range(nw):
            bg.paste(fg, (l * fg.size[0], t * fg.size[1]))
    return bg
