A potential agreement is taking shape that could see Iran release prisoners in exchange for billions of dollars in sanctioned funds.