Improve search for dynamic libraries

Now, dynamic libraries are searched in these places:
 1. Current working directory
 2. Current import paths (for example, from loaded packages)
 3. The system paths for dynamic libs

Fixes #861.
Merge pull request #869 from david-christiansen/dynamic-lib-search

Improve search for dynamic libraries