Sirius explains in the third or fourth book that the thought of his innocence and revenge kept him from being affected by the Dementors. He later says that he got a Daily Prophet and saw Peterpettigrew after that he knew he had to escape so he did.
Quoted from the Harry Potter answer wikia:
His knowledge of his innocence allowed him to retain his powers and
sanity. 'One night, when (the Dementors) opened my door to bring food,
I slipped past them as a dog. It's so much harder for them to sense
animal emotions that they were confused ... I was thin enough to slip
through the bars. I swam as a dog back to the mainland. I journeyed
north and slipped into the Hogwarts grounds as a dog. I've been living
in the Forest ever since.' Prisoner of Azkaban; chapter 'The Servant
of Lord Voldemort'http://harrypotter.answers.wikia.com/wiki/How_did_Sirius_Black_escape_from_Azkaban
This Quote is from the Harry Potter wikia, but its sort of conjectural(at least the article said that), it matches the other answers though
In 1993, Sirius Black escaped from Azkaban after seeing Scabbers in a
Daily Prophet article, of the paper Cornelius Fudge gave him, in July
1993, recognising him as his traitorous former friend Peter Pettigrew.
By 1 August, Black took advantage of his extreme weight loss to slip
through his cell door in his Animagus dog form (which was
unregistered, thus the Ministry did not take preparations against)
while the Dementors were bringing in his food and swam across the
North Sea to find Pettigrew.Black was able to maintain his sanity
due to his knowledge of his innocence, a non-happy thought that the
Dementors could not take. It was only this that allowed him to
maintain his powers to transform, and what made the escape possible.
This escape was the only known unaided escape, and officially the
first one in Azkaban history (until Barty Crouch Jr.'s escape was
revealed). Black was facing the Dementor's Kiss as punishment should
he ever be recaptured, though he ultimately eluded the Ministry, and
his name was cleared shortly after his death at the hands of Bellatrix
Lestrange in the Department of Mysteries.http://harrypotter.wikia.com/wiki/Azkaban_escapes
And this link is to a question from the movies stack exchange-
It explains the mechanics to escape.