It would be unusual to be asked to give 3 months notice - I have only ever come across this in teaching where commitment to an exam class and the 3-monthly organisation of terms is important. And even witihin teaching, when you gotta go they can't force you to stay. Notice terms are usually linked to how you are paid ie a month if you are paid monthly, a week if you are paid weekly. This is cos you employer is usually hanging onto a payment in arrears in case you flit without notice. So if you intend going to your new job, go anyway but bear in mind that if you don't give the right written notice they may hang on to some of your pay.
Write your standard resignation letter saying you wish to tender 4 weeks notice of your intention to leave their employ.
But unless you are a teacher I really doubt any firm can expect 3 months notice.