Indeed Orochimaru could not reanimate the Hokages while their soul were not in the "Pure World", in other words, while they are sealed inside the Shinigami's stomach.
But at chapter 618, Orochimaru summoned and controled the Shinigami with the help of Shinigami's mask:
So he was able to remove the seal if he cuts his on stomach, using the technique: Dead Demon Consuming Seal: Release.
With the Hokage's souls relesead, he could reanimate them.
At Naruto Wiki, this technique is well explained:
This technique involves invoking the Shinigami using a mask from the
Uzumaki Clan's Mask Storage Temple. From there, the summoner is
possessed by the Shinigami allowing them control over it, they can
then force it to cut its own stomach resulting in the release of the
souls sealed inside. Due to the possession however, the same damage
will reflect on the invoker's own body.
After the souls are released, however, persons are free to do as they
please with the souls. Orochimaru used this technique to free the
souls of the Hokage along with that of his arms and then reincarnate