Suppose I develop a useful library and decide to publish it as open source. Some time later I have a business need to do something that wouldn't comply with the open source licence. Am I allowed to do that?

How should I publish the software in a way that I keep ownership and don't block myself from using the library in the future in any way?

Keep in mind that at least in theory, other developers may decide to contribute to my open-source project. Can I specify in a licence that I as the original developer get ownership of their contributions as well? Don't get me wrong here, I'm not trying to be evil and get ownership of other's work - I just want to keep ownership of mine, and if someone posts an important bugfix I could be rendered unable to use the original code unless I use his work as well.

You always keep ownership under open-source licenses.  The work you created is your property, and you can do whatever you want to with it, (within legal limits, of course,) including allowing other people to use it under the terms of an open-source license.  If you want to use it for a proprietary project, you're welcome to do so, unless you have completely turned over the rights to someone else by contract.  But this is not what open-source licenses do.  They're about sharing usefulness, not about giving up ownership.

Things get a bit sticker once other people start contributing.  It's their work, then, not yours, and you need to get their permission.  One thing you can do is publish your library under a dual license.  That's what Sam Lantinga, the primary creator and maintainer of SDL, does.  Because Apple doesn't like dynamic link libraries for iOS, and complying with the LGPL in a statically linked app is more trouble than it's worth, he publishes SDL under both the LGPL and a commercial license for static iPhone apps.  When anyone submits a patch, he explicitly asks them for permission to deploy their patch in the library under both licenses, and if they don't like that, he doesn't add it to the codebase.

EDIT: My example is no longer accurate.  A while back Sam changed the model (not sure why; maybe he just got tired of the administration hassles) and now licenses SDL under a highly permissive zlib-style license.  But he used to do it this way.
