The Grade II listed Barmouth Bridge, in Gwynedd, is to undergo a £25m upgrade to protect it for visitors in the future.