Why do you need to know which side the collision was on? All you need to know is that the pacman collided with a non-transparent pixel of the maze.
Check the movement key from the player, check whether Pacman's new position would collide with the wall image. If it does don't allow the move.
Check the movement key from the player, check whether Pacman's new position would collide with the wall image. If it does don't allow the move.