Pose mirroring wrong

Hello, Blender newbie here. I have a problem mirroring poses that’s giving me a headache. When I mirror for example the left leg the right leg isn’t correctly mirrored, it’s rotated for some reason.

I’ve read possible solutions and watched some videos, but I still get bad results.

This is what I do.
First I create the bones I need.

https://s32.postimg.org/jwe4vw70h/blender1.jpg

I place the 3D cursor at (0, 0, 0).
I select all of them except torso and head bones. I press SHIFT+D, ESC, CTRL+M, X, ENTER
to create a mirrored copy. Then I press W and select flip names.

https://s32.postimg.org/ytmlwwk8x/blender2.jpg

Once that is done, I go to pose mode and move some bones on the right side:

https://s32.postimg.org/5fqvhbhj5/blender3.jpg

Then, with those bones selected, I press CTRL+C, CTRL+SHIFT+V to paste mirrored,
but this is what happens.

https://s32.postimg.org/549f4k135/blender4.jpg

What could I possibly be doing wrong?