Croatia's Marin Cilic beat Denis Istomin in three sets to reach the second round of the Toronto Masters.