Sirius Black is a very strong wizard and was waiting for the opportunity to spot Peter Pettigrew for the thirteen years he was in Azkaban. So, when he saw the photograph of the Weasleys in Egypt along with Ron holding Scabbers, who has a finger missing, Sirius transformed into his Animagus form of the black dog and escaped the prison. Dementors can only sense complex beings like humans because of their thoughts which is why he couldn't be spotted by the dementors.