An improved implementation of boundary integral equation method to compute two-dimensional magnetic field