The iPhone is to go on sale in Spain and Japan for the first time, after Apple agrees deals with mobile operators.