Improve: support for $mode parameter

Requires PHP version > 5.4.28/5.5.12.
See: https://bugs.php.net/bug.php?id=67064.