I'm assuming that MIA is a stop you need to make--otherwise, I'd say to use Iberia directly to Quito.
When you are checking prices for side trips, I'd look at Miami-Lima and do the RT to Quito from LIM--I'm pretty sure it can be done locally for about $200.00. (mas o menos).