a function to merge two images