Topological strings and large N phase transitions I: Nonchiral expansion of q-deformed Yang-Mills theory