Here is an idea just off the top of my head -
on collision with wall, remember current object position in variables tempX, tempY. Set a random angle, move object about 20px at that angle, check if it's overlapping the wall. If it is, return it to (tempX, tempY) and repeat.
If it is not overlapping, then it's safe to bounce at that angle, return object to (tempX, tempY) and set bullet angle of motion to it.