A professor whose idea of a good or even appropriate letter of recommendation is to copy a letter off of the internet and send it to you is a knucklehead. (That is a technical term: I am after all an academic professional. I could have used stronger language...) At least, he is in this respect: in the comments the OP mentions that he got a job at Waterloo, which is a university with a high international reputation. So he must have some other good things going for him. In the fullness of time, I have to believe that he will learn how to write a reasonable recommendation letter.
But that's not your problem. I would advise you to look at the fact that the professor gave the letter directly to you -- which is itself irregular and, in certain circles, inappropriate -- as a real blessing. He could have just sent this miserable excuse for a letter quietly to all the places you're applying to, and you would be the one (in the short term, at least) to suffer the consequences. I strongly disagree that you should work further with this guy to write a better letter. (In particular, I vehemently disagree that you should write the letter yourself. As I have said before on this site, I find that "immoral and wrong" -- a recommendation letter is a commissioned expert opinion. Looking over the opinion desired by the person you have been commissioned to evaluate and deciding whether or not it requires any modification is not how expert opinions work. But I've made my feelings on this moral issue clear enough already. Here let me push the practical side of this: as a student, you cannot write for yourself a good recommendation letter. There are components of such a letter that require expertise and personal experience that you necessarily lack.) It is time to start fresh and get a letter from a new person.
The part of your response that jumps out at me is "I can't find a third professor other than him who is willing to write a letter for me." That's the real issue here, and I hope it will serve as a warning to other students in your position. All undergraduates should be thinking -- from their first year -- about building good relationships with their instructors that will lead to multiple people being able to write them strong recommendation letters. It is all too easy to go through an undergraduate program -- even, perhaps especially, to excel at it -- while having very little contact with the faculty outside of the classroom and regular coursework. That is certainly a mistake.
Okay, though: what do you do? You ask whether someone who has not taught you in a course can write you a letter. The answer is certainly yes. You want the letter writer to (i) have stature in the academic community and in the particular area you're applying to, and (ii) have something meaningful to say about your academic background, skills, work ethic, and prospects for success in graduate school. Someone that you have done research with can speak to aspects of that as well or better as people who have taught you in a course in which you quietly got an A. In a pinch -- as you seem to be -- I would advise you to try to make contacts with people who satisfy condition (i) and try to rapidly achieve (ii) with them. Thus for instance if you've done any research at all in the field you're intending to study, you could send a paper (or code, or interesting data, or whatever) to an expert in that field and mention that you'd like a recommendation letter. This is a bit irregular, but if your work is solid, why not? I would do it.
I strongly recommend that you work harder to find the right person to write you a strong letter than to have further dealings with someone who has already proven to be hopelessly inept at the job.