General solution scheme for second order differential equations: application to quantum transport