Need advice and roadmap!

I have an acquantance who has a house that needs about $25k of rehab in order to get $285k retail. He has had it on the market for $239k, but without much interest. He owes $100k and I have told him I will give him $200k with conditions! These conditions are that we sign an agreement that I will pay his current mortgage payments until my renovations are complete and the house is sold, then he will receive the proceeds of the sale up to $200k and the remainder is mine!
How is this accomplished and are there any legal ramifications?
Thanks,
TB