I have looked after a biting two year old (my God Daughter). Biting tends to be copied from other children (as you probably already know). When my God Daughter bit either myself or her baby brother, I tended to put her in time out - this stopped her really quickly. Now I only have to warn her and she stops biting (or hitting, spitting etc). All that you do is tell your 2 yr old what he has done wrong, then (without talking to him again) put him in a safe (preferably boring) room or place for two minutes. After the two minutes, let him out, and if you want, get him to say sorry to whoever he hurt.
As for the biting himself, it may be attention seeking. My God Daughter used to fdo it too, I just ignored it and she stopped after a while.