Efficient algorithm and analysis for the Yang-Mills equations with temporal gauge