Sorry to hear of the issue.
We can't write a letter for you as we are not a law firm - we are an internet forum and we can give online Q&A information and guidance only.
The issue for a landlord who has not protected their deposit within the 30 day prescribed period is that you are liable for at least one times the deposit sum. There is no way around this unfortunately. The law is strict so even if you were 1 day later, the tenant is entitled to compensation. The court can award anything between 1 and 3 times the sum - depending how grave the breach was, your conduct, if you simply forgot, whether you are an experienced landlord, etc.
This would not be a small claims case so you could propose a "Part 36" offer to the tenant. The court may be likely to just award them x1 of the deposit sum, so you could make them an offer of one times the deposit sum or slightly more - if the tenant is only awarded one times then you can claim any defence costs as they will have dragged you to court and not beaten your offer.
The judge would not know about this offer until the case has finished and when the issue of costs is concerned.
The Part 36 offer has to follow the criteria under Part 36 of the Civil Procedure Rules to be valid - see link : Part 36 CPR
I have attached a template as an example for you which you may find useful.
If you would prefer a law firm to do this, here are a few choices for you :
1. Knights Law, tel: 01204 655614, email:***@******.***
2. Stephensons Solicitors, tel: 0161(###) ###-####
3. Duncan Lewis, tel: 0333(###) ###-####