Unfortunately the border between Algeria and Spain is indeed closed. You could possibly get round it by going Algeria-Mali-Mauritania-Western Sahara/Morocco, but Northern Mali isn't especially safe at the moment. You could get round this by going through Niger and then Mali from Algeria, but Niger isn't that much safer, and you would have to pay for a guide as well. You would also need a guide in Algeria, and in Libya.
Libya itself is a bit of a nightmare when it comes to officialdom, as is Egypt. You might have serious issues taking bikes through both of these countries. On the other hand, if you're able to deal with Iranian officialdom, then you should be able to cope with Egypt and Libya.
One other option, although far less fun, is to go from Iran through Turkey and Europe. You would find it easier, and with the restrictions on travel in Libya you might also find it more interesting.